package com.bentley.kotlindemo.net

import com.bentley.kotlindemo.net.RespStatus.SUCCESS
import com.bentley.kotlindemo.net.RespStatus.ERROR
import com.bentley.kotlindemo.net.RespStatus.LOADING


/**
 * <pre>
 *  ┌────────────────────────────────────────────
 *  │ @author  Lee  @date 2021/3/16 14:49
 *  ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
 *  │ @desc  网络请求响应结果
 *  └────────────────────────────────────────────
 * </pre>
 */
data class RespResult<out T>(val status: RespStatus, val data: T?, val message: String?) {
    companion object {
        fun <T> success(data: T): RespResult<T> =
            RespResult(status = SUCCESS, data = data, message = null)

        fun <T> error(data: T?, message: String): RespResult<T> =
            RespResult(status = ERROR, data = data, message = message)

        fun <T> loading(data: T?): RespResult<T> =
            RespResult(status = LOADING, data = data, message = null)
    }
}

